package com.zgl.airoleplay.controller;

import com.zgl.airoleplay.service.AiService;
import com.zgl.airoleplay.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/ai")
public class AiController {
    @Autowired
    private AiService aiService;

    // 接收前端请求，获取AI回复
    @PostMapping("/getAi")
    public Result getAIReply(@RequestBody Map<String, String> param) {
        String userInput = param.get("userInput");
        String roleName = param.get("roleName");
        Map<String, Object> aiReply = aiService.getLLMAndVoiceReply(userInput, roleName);
        return Result.success("200", "AI回复生成成功", aiReply);
    }

}
